package org.example.book.bridge.abst;

import org.example.book.bridge.RegisterLoginFuncInterface;
import org.example.book.pojo.UserInfo;

import javax.servlet.http.HttpServletRequest;


/**
 * @author jeff
 */
public abstract class AbstractRegisterLoginComponent {
    protected RegisterLoginFuncInterface registerLoginFuncInterface;

    public AbstractRegisterLoginComponent(RegisterLoginFuncInterface registerLoginFuncInterface) {
        validate(registerLoginFuncInterface);
        this.registerLoginFuncInterface = registerLoginFuncInterface;
    }

    private void validate(RegisterLoginFuncInterface registerLoginFuncInterface) throws UnsupportedOperationException {
        if (registerLoginFuncInterface == null) {
            throw new UnsupportedOperationException("RegisterLoginFuncInterface must be instance of RegisterLoginFuncInterface");
        }
    }

    protected abstract String login(String username, String password);

    protected abstract String register(UserInfo userInfo);

    protected abstract boolean checkExists(String username);

    protected abstract String login3rd(HttpServletRequest request);
}
